const fs = require('fs')
const url = require('url')
const http = require('http')

http.createServer((req, res) => {
  const { pathname } = url.parse(req.url)
  res.statusCode = 200;
  if (~pathname.indexOf('api')) {
    setTimeout(() => {
      res.end('Hello world')
    }, 1000)
  } else {
     // fs.createReadStream(__dirname + '/event-loop.js').pipe(res)
     fs.createReadStream('./CanWait/canWait.html').pipe(res);
  }
}).listen(4000)
